<template>
  <div>
    parent
    <button @click="emit2Child">to Child </button>
    <Child1></Child1>

  </div>
</template>

<script>
  import eventHub from './eventHub.js'
  import Child1 from './Child1.vue'
  export default {
    components: {
      Child1
    },
    data() {
      return {
        pForms: []

      };
    },
    computed: {

    },
    mounted() {

    },
    created() {
      // 监听
      eventHub.$on('forms', this.getForms)
    },
    beforeDestroy() {
      // 注销组件同时注销监听,防止bug
      eventHub.$off('forms', this.getForms)
    },
    methods: {
      async asyncBlock(s) {
        let sIt = {
          // apply: {
          //   'checkPlanId': s.where.checkPlanId,
          //   'checkContId': s.where.checkContId,
          //   'studentId': s.where.studentId
          // },
          // 'checkItemIds': [s.where.checkItemId]
        }
        let applyDetailList = await Promise.all(s).then(([...f]) => {
          return f
        })


        return sIt
      },
      async emit2Child() {
        // 向下
        eventHub.$emit('submit', '1312')
        // console.log(this.pForms)

        Promise.all(this.pForms).then(re => {
            console.log(re)
            alert('changg')
          })
          .catch(e => {
            this.$message.error('请检查输入情况！')
            this.pForms=[]
            return false
          })
        // let reqData = await
        //   .then(re => {
        //     // return re
        //     alert('changg')
        //   })
        //   .catch(e => {
        //     this.$message.error('请检查输入情况！')
        //     return false
        //   })


      },

      getForms(kk) {
        this.pForms.push(kk)
      },
    },

    watch: {

    }
  };
</script>

<style scoped lang="less">

</style>
